package com.cy.核心编程.stream.update;

import java.io.*;

public class Test {
    public static void main(String[] args) throws Exception {
        File res = new File("src/唐诗三百首.txt");
        File another = new File("src/副本_唐诗三百首.txt");
        BufferedReader br = new BufferedReader(new FileReader(res));
        BufferedWriter bw = new BufferedWriter(new FileWriter(another));

        String line = "";
        while((line = br.readLine())!=null){
            line = line.replace("李白", "李太白");
            bw.write(line);
            bw.newLine();
        }
        br.close();
        bw.flush();
        bw.close();

        res.delete();
        another.renameTo(res);
    }
}
